
package me.zhengjie.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.service.AppEventService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;


/**
* @website https://el-admin.vip
* @author IQW
* @date 2022-07-03
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "后台首页接口")
@RequestMapping("/api/index")
public class AppIndexController {

    @Value("${site.url}")
    private String siteUrl;

    private final UserService userService;


    @GetMapping
    @ApiOperation("首页统计数据")
    public ResponseEntity<Object> index(){

        Map<String,Object> rets = new HashMap<>();

        Integer all = userService.selAllCount(0);
        Integer zhy = userService.selAllCount(1);
        Integer lz = userService.selAllCount(2);

        rets.put("allman",all);
        rets.put("hlyman",zhy);
        rets.put("lzman",lz);

        String[] tmp1 = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};
        int[] int1 = {4, 4, 3, 4, 5, 6, 7};
        int[] int2 = {1, 2, 7, 8, 9, 6, 4};

        rets.put("data", tmp1);
        rets.put("data1",int1);
        rets.put("data2",int2);

        int[] int3 = {1, 4, 3, 4, 5, 6, 7};
        Map<String,Object> sjsb = new HashMap<>();
        sjsb.put("num",12);
        sjsb.put("tage",0.3);
        sjsb.put("list",int3);
        rets.put("sjsb",sjsb);

        int[] int4 = {1, 2, 8, 4, 2, 5, 2};
        Map<String,Object> sjcl = new HashMap<>();
        sjcl.put("num",5);
        sjcl.put("tage",0.1);
        sjcl.put("list",int4);
        rets.put("sjcl",sjcl);

        Map<String,Object> rwdd = new HashMap<>();
        rwdd.put("num",12);
        rwdd.put("num1",4);
        rwdd.put("num2",8);
        rets.put("rwdd",rwdd);

        Map<String,Object> kqgl = new HashMap<>();
        kqgl.put("num",6);
        kqgl.put("num1",3);
        kqgl.put("num2",3);
        rets.put("kqgl",kqgl);

        return new ResponseEntity<>(rets,HttpStatus.OK);
    }

    @GetMapping(value = "/menu")
    @ApiOperation("定制菜单")
    public ResponseEntity<Object> menu(){

        List<Map> rets = new LinkedList<>();

        Map<String,Object> tmp1 = new HashMap<>();
        tmp1.put("id",1);
        tmp1.put("title","巡护任务");
        tmp1.put("img",siteUrl +"/file/20220815/icon_1-20220815041553198.png");
        tmp1.put("path","/member/renwu");
        tmp1.put("check",1);
        rets.add(tmp1);

        Map<String,Object> tmp2 = new HashMap<>();
        tmp2.put("id",2);
        tmp2.put("title","事件管理");
        tmp2.put("img", siteUrl +"/file/20220815/icon_2-20220815041620922.png");
        tmp2.put("path","/member/shijian");
        tmp2.put("check",1);
        rets.add(tmp2);

        Map<String,Object> tmp3 = new HashMap<>();
        tmp3.put("id",3);
        tmp3.put("title","文件管理");
        tmp3.put("img",siteUrl + "/file/20220815/icon_3-2022081504163626.png");
        tmp3.put("path","/resources/wendang");
        tmp3.put("check",1);
        rets.add(tmp3);

        Map<String,Object> tmp4 = new HashMap<>();
        tmp4.put("id",4);
        tmp4.put("title","基础管理");
        tmp4.put("img",siteUrl + "/file/20220815/icon_4-20220815041648753.png");
        tmp4.put("path","/resources/biaojidian");
        tmp4.put("check",1);
        rets.add(tmp4);

        Map<String,Object> tmp5 = new HashMap<>();
        tmp5.put("id",5);
        tmp5.put("title","通知管理");
        tmp5.put("img",siteUrl + "/file/20220815/icon_5-20220815041705777.png");
        tmp5.put("path","/message/xiaoxi");
        tmp5.put("check",1);
        rets.add(tmp5);

        return new ResponseEntity<>(rets,HttpStatus.OK);
    }


}